import React, { Component } from 'react'
import { getChannels } from '../../api/channel'

export default class Index extends Component {
  state = {
    channels: []
  }

  getChannelsData = async () => {
    const res = await getChannels()

    this.setState({
      channels: res.data
    })
  }

  componentDidMount () {
    this.getChannelsData()
  }

  render () {
    return (
      <div>
        Index
        <ul>
          {this.state.channels.map(item => {
            return (
              <li key={item.id}>
                {item.id} {item.name}
              </li>
            )
          })}
        </ul>
      </div>
    )
  }
}
